/*md5加密生成Token*/
function createToken(obj){
	var str="";
	Object.keys(obj).sort().forEach(function(item, index) {
        str += obj[item]
    })
	return md5(str+"123456");
}
/*URL取值*/
function getUrlParams(name){
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if(r!=null)return  unescape(r[2]); return null;
}
/*object对象合并*/
function extend(o,n){
   for (var p in n){
        if(n.hasOwnProperty(p) && (!o.hasOwnProperty(p) ))
            o[p]=n[p];
    }
};  

/*http请求统一封装*/
function http(url,type,data,callback){
    if (!data) { data = {} }
    if (!data.platform) { data.platform = 'h5' }
    if (data.identify) { data.identify = $utils.getIdentify() }
    if (!data.allcookies) {
        data.allcookies = document.cookie
    }
    if (!data.token) {
        var token = createToken(data)
        data.token = token
    }
	$.ajax({
	   	method: 'GET',
	   	dataType:'json',
	   	url:url,
	    data:data,
	    withCredentials:true,
	    success: function (res,xhr) {
	       callback(res);
	    },
	    error:function(res,xhr){
	        callback(data);
	    }
	});
}
/*httpGet请求*/
function httpGet(url,data,callback){
	http(url,'get',data,callback)
}
/*httpPost请求*/
function httpPost(url,data,callback){
	http(url,'post',data,callback)
}